package com.garen.projects.demo.provider.service.impl;

import com.garen.projects.demo.provider.model.user.UserQuery;
import com.garen.projects.demo.provider.service.UserService;
import com.google.common.collect.ImmutableMap;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UserServiceImpl implements UserService {

    private Map<Long, String> users = ImmutableMap.<Long, String>builder()
            .put(1L, "张三")
            .put(2L, "李四")
            .put(3L, "王五")
            .put(4L, "赵二")
            .build();

    @Override
    public UserQuery query(Long id) {
        if (id != null && users.containsKey(id)) {
            return new UserQuery(id, users.get(id));
        } else {
            return null;
        }
    }
}
